package com.gj.hiltsample

import android.os.Bundle
import android.util.Log
import android.widget.TextView
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.fragment.app.FragmentActivity
import com.gj.hiltsample.ui.theme.HiltSampleTheme
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class MainActivity : FragmentActivity() {

    @Inject
    lateinit var application: AppApplication

    @Inject
    lateinit var application1: AppApplication

    @Inject
    lateinit var dateFormatter: DateFormatter

    @Inject
    lateinit var classDAO: ClassDAO
    @Inject
    lateinit var classDAO1: ClassDAO

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val textView = findViewById<TextView>(R.id.txt_view)
        textView.setOnClickListener {
            startActivity(SecondActivity.newIntent(this))
        }

        Log.d("GJ", "onCreate $application")
        Log.d("GJ", "onCreate1 $application1")
        Log.d("GJ", "current time:${dateFormatter.formatDate(System.currentTimeMillis())}")
        Log.d("GJ", "getStudent:${classDAO.getStudent()}")
        Log.d("GJ", "getStudent:${classDAO1.getStudent()}")
    }
}